package com.rainbow.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rainbow.entity.Position;
import com.rainbow.mapper.PositionMapper;
import com.rainbow.service.PositionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author rainbow
 **/
@Service
@Transactional
public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> implements PositionService {

    @Override
    public int addPos(Position pos) {
        if (baseMapper.getPosByName(pos.getName()) != null) {
            return -1;
        }
        return baseMapper.addPos(pos);
    }

    @Override
    public List<Position> getAllPos() {
        return baseMapper.getAllPos();
    }

    @Override
    public boolean deletePosById(String pids) {
        String[] split = pids.split(",");
        return baseMapper.deletePosById(split) == split.length;
    }

    @Override
    public int updatePosById(Position position) {
        return baseMapper.updatePosById(position);
    }
}
